{% extends "base.html" %}

{% block head %}
  <script type="text/javascript">
  //<![CDATA[

  function checkForm(theForm) {
    var checkedMatchName = theForm.checkedMatchName;
    var content = theForm.content;
    
    if(content.value.length <= 0) {
      alert("没有要检查的URL啊！");
      return false;
    }
    for(i = 0; i < theForm.matchConf.length; i++) {
      if(theForm.matchConf[i].checked) {
        checkedMatchName.value += "," + theForm.matchConf[i].match;
      }
    }
    if(checkedMatchName.value.length <= 0) {
      alert("请选择检查的选项哦！");
      return false;
    }
    checkedMatchName.value = checkedMatchName.value.substr(1);
    document.getElementById('submitButton').disabled = true;
    return true;
  }
  </script>
{% endblock %}

{% block body %}
    <form action="/check" method="post" onSubmit="return checkForm(this)">
      <input type="hidden" name="checkedMatchName"/>
      <div>输入要检查的URL(多个URL可以按行分隔，建议最多检查5个链接)：</div>
      <div><textarea name="content" rows="8" cols="60"></textarea></div>
      <div><p>检查选项：
      {% if matchs %}
        {% for m in matchs %}
          <input type="checkbox" checked="true" name="matchConf" id="{{m.key.id}}" value="{{m.matchCode}}" match="{{m.name}}"><label for="{{m.key.id}}" title="{{m.matchCode}}">{{m.name}}</label></input>&nbsp;&nbsp;
        {% endfor %}
      {% endif %}
      <br/>没有你想要的选项？<a href="mailto:javaone@gmail.com">请联系我安排添加：）</a>
      </p></div>
      <div><p><input id="submitButton" type="image" src="/static/checknow.png"></p></div>
    </form>
{% endblock %}
